# a @ b：矩阵乘法[同维度] == np.dot(a, b)
# a * b：点积->矩阵
# np.vdot(a, b)：算数值点积
# np.matmul(a, b)：矩阵乘法，可以不同维度，一维和二维->一维；二维和三维->三维
# np.linalg.det(a)：算行列式
# np.linalg.inv(a)：算逆矩阵
# np.linalg.solve(a, b)：求线性方程组的解


# import numpy as np
#
# a = np.array([[1, 2], [3, 4]])
# b = np.array([[11, 12], [13, 14]])
# print(np.dot(a, b))
# print(a@b)

# import numpy as np
#
# a = np.array([[1, 2], [3, 4]])
# b = np.array([[11, 12], [13, 14]])
#
# # vdot 将数组展开计算内积，得到的是一个数据
# print(np.vdot(a, b))

# import numpy as np
#
# a = np.array([[1, 2], [3, 4]])
#
# print('数组 a：')
# print(a)
# b = np.array([[11, 12], [13, 14]])
#
# print('数组 b：')
# print(b)
#
# print('内积：')
# print(np.inner(a, b))
# print(a * b)

# import numpy as np
#
# a = [[1, 0], [0, 1]]
# b = [1, 2]
# print(np.matmul(a, b))
# print(np.matmul(b, a))
#
# a = np.arange(8).reshape(2, 2, 2)
# b = np.arange(4).reshape(2, 2)
# print(np.matmul(a, b))

# import numpy as np
#
# a = np.array([[1, 2], [3, 4]])
# b = np.arange(9).reshape(3, 3)
# print(np.around(np.linalg.det(a), 1))
# print(np.linalg.det(b))
#
# b = np.array([[6, 1, 1], [4, -2, 5], [2, 8, 7]])
# print(b)
# print(np.linalg.det(b))
# print(6 * (-2 * 7 - 5 * 8) - 1 * (4 * 7 - 5 * 2) + 1 * (4 * 8 - -2 * 2))

# import numpy as np
#
# x = np.array([[1, 2], [3, 4]])
# y = np.linalg.inv(x)
# print(x)
# print(y)
# print(np.dot(x, y))

import numpy as np

a = np.array([[1, 1, 1], [0, 2, 5], [2, 5, -1]])

# print('数组 a：')
# print(a)
# ainv = np.linalg.inv(a)
#
# print('a 的逆：')
# print(ainv)

print('矩阵 b：')
b = np.array([[6], [-4], [27]])
print(b)

print('计算：A^(-1)B：')
x = np.linalg.solve(a, b)
print(x)
# 这就是线性方向 x = 5, y = 3, z = -2 的解